﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsHopDongChiTiet
    {
        private double mDonGia = 0.0;
        private double mDonGiaNT = 0.0;
        private string mDonViTinh = "";
        private string mKhoa = "";
        private string mKhoaHopDong = "";
        private double mSoLuong = 0.0;
        private string mTen = "";
        private double mThanhTien = 0.0;
        private double mThanhTienNT = 0.0;
        private int mThueSuat = 0;
        private double mTienThue = 0.0;
        private double mTienThueNT = 0.0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM ST_NhapKhoChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHopDong = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mTen = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mSoLuong = Conversions.ToDouble(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetDecimal));
                    this.mDonViTinh = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mDonGiaNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetDecimal));
                    this.mDonGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetDecimal));
                    this.mThanhTienNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetDecimal));
                    this.mThanhTien = Conversions.ToDouble(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetDecimal));
                    this.mThueSuat = Conversions.ToInteger(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThueNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetDecimal));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[12];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaHopDong", DbType.Int64, ParameterDirection.Input, this.mKhoaHopDong);
                commandParameters[2] = DBHelper.createParameter("@Ten", DbType.Int64, ParameterDirection.Input, this.mTen);
                commandParameters[3] = DBHelper.createParameter("@SoLuong", DbType.Date, ParameterDirection.Input, this.mSoLuong);
                commandParameters[4] = DBHelper.createParameter("@DonViTinh", DbType.Int64, ParameterDirection.Input, this.mDonViTinh);
                commandParameters[5] = DBHelper.createParameter("@DonGiaNT", DbType.Date, ParameterDirection.Input, this.mDonGiaNT);
                commandParameters[6] = DBHelper.createParameter("@DonGia", DbType.Date, ParameterDirection.Input, this.mDonGia);
                commandParameters[7] = DBHelper.createParameter("@ThanhTienNT", DbType.Date, ParameterDirection.Input, this.mThanhTienNT);
                commandParameters[8] = DBHelper.createParameter("@ThanhTien", DbType.Date, ParameterDirection.Input, this.mThanhTien);
                commandParameters[9] = DBHelper.createParameter("@ThueSuat", DbType.Double, ParameterDirection.Input, this.mThueSuat);
                commandParameters[10] = DBHelper.createParameter("@TienThueNT", DbType.Date, ParameterDirection.Input, this.mTienThueNT);
                commandParameters[11] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                if (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "CO_sp_HopDongChiTiet", commandParameters) > 0)
                {
                    return true;
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public double DonGia
        {
            get
            {
                return this.mDonGia;
            }
            set
            {
                this.mDonGia = value;
            }
        }

        public double DonGiaNT
        {
            get
            {
                return this.mDonGiaNT;
            }
            set
            {
                this.mDonGiaNT = value;
            }
        }

        public string DonViTinh
        {
            get
            {
                return this.mDonViTinh;
            }
            set
            {
                this.mDonViTinh = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaHopDong
        {
            get
            {
                return this.mKhoaHopDong;
            }
            set
            {
                this.mKhoaHopDong = value;
            }
        }

        public double SoLuong
        {
            get
            {
                return this.mSoLuong;
            }
            set
            {
                this.mSoLuong = value;
            }
        }

        public string Ten
        {
            get
            {
                return this.mTen;
            }
            set
            {
                this.mTen = value;
            }
        }

        public double ThanhTien
        {
            get
            {
                return this.mThanhTien;
            }
            set
            {
                this.mThanhTien = value;
            }
        }

        public double ThanhTienNT
        {
            get
            {
                return this.mThanhTienNT;
            }
            set
            {
                this.mThanhTienNT = value;
            }
        }

        public int ThueSuat
        {
            get
            {
                return this.mThueSuat;
            }
            set
            {
                this.mThueSuat = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public double TienThueNT
        {
            get
            {
                return this.mTienThueNT;
            }
            set
            {
                this.mTienThueNT = value;
            }
        }
    }
}

